package com.gitee.zhangchenyan.takin.common.utils;

import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;

/**
 * @Deacription 密码生成器
 * @Author zl
 * @Date 2022/4/17 17:05
 * @Version 1.0
 **/
public class PassWordUtils {
    private static final String salt = "tiMg7LcrqJ^hvkEp123yNVK&%GB()!";

    public static String getEncryptPass(String pass) {
        return DigestUtils.md5DigestAsHex((pass + salt).getBytes(StandardCharsets.UTF_8));
    }

    public static boolean getVerifyPass(String pass, String dbPass) {
        String encryptPass = DigestUtils.md5DigestAsHex((pass + salt).getBytes(StandardCharsets.UTF_8));
        return encryptPass.equals(dbPass);
    }
}
